<template>
  <div class="map">
    <pre>
      Array.prototype.my_map = function (fn) {
        if (!Array.isArray(this) || !this.length || typeof fn !== 'function') {
          return []
        } else {
          let res = []
          for (let i=0; i < this.length; i++) {
            res.push(fn(this[i], i, this))
          }
          return res
        }
      }
    </pre>
  </div>
</template>
 
<script>
export default {
  name: 'map',
  data () {
    return {
      msg:''
    }
  }
}
</script>
 
<style scoped lang="less">
 
</style>